#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char* argv[])
{
    char Proc_File[32] = "/proc/stat";
    FILE* fp = fopen(Proc_File, "r");
    if (fp == NULL)
    {
        perror("open file failed\n");
        return -1;
    }

    int count = 10;
    char buf[1024] = { 0 };
    while (count--)
    {
        while (fgets(buf, sizeof(buf), fp) != NULL)
        {
            printf("%s", buf);
        }
        fseek(fp, 0, SEEK_SET);
        printf("-----已到达末尾,重新读取 count=%d\n",count);
        sleep(1);
    }
    fclose(fp);

    return 0;
}

/* 运行结果  --ok
读取 /proc/stat 到达文件末尾后, 重新读取

*/